fix: correct on-call filter params and add name-based filtering#34
fix: correct on-call filter params and add name-based filtering#34jeffreytolar wants to merge 2 commits into
Conversation
Greptile SummaryFixes the
Confidence Score: 4/5Safe to merge; the core bug fixes are correct and the new name-resolution paths are well-tested. The pluralization fix and resolver helpers are solid. The one rough edge is that the URL-encoding hardening applied to five other list functions in this PR was not extended to the ListOnCallsCLI filter values — if an ID flag ever contains a special character, those filters would be silently dropped. That gap is unlikely to bite in practice given Rootly's ID format, but it is inconsistent with the rest of the change. internal/api/client.go — specifically the ListOnCallsCLI filter-value concatenation block (lines 2965–2979) and the multi-result guard in ResolveUserID (around line 202). Important Files Changed
|
| if params.ScheduleIDs != "" { | ||
| qp = append(qp, "filter[schedule_id]="+params.ScheduleIDs) | ||
| qp = append(qp, "filter[schedule_ids]="+params.ScheduleIDs) | ||
| } | ||
| if params.ServiceIDs != "" { | ||
| qp = append(qp, "filter[service_id]="+params.ServiceIDs) | ||
| qp = append(qp, "filter[service_ids]="+params.ServiceIDs) | ||
| } | ||
| if params.EscalationPolicyIDs != "" { | ||
| qp = append(qp, "filter[escalation_policy_id]="+params.EscalationPolicyIDs) | ||
| qp = append(qp, "filter[escalation_policy_ids]="+params.EscalationPolicyIDs) | ||
| } | ||
| if params.UserIDs != "" { | ||
| qp = append(qp, "filter[user_id]="+params.UserIDs) | ||
| qp = append(qp, "filter[user_ids]="+params.UserIDs) | ||
| } | ||
| if params.GroupIDs != "" { | ||
| qp = append(qp, "filter[group_ids]="+params.GroupIDs) | ||
| } |
There was a problem hiding this comment.
OnCalls filter values not URL-encoded
The ListIncidentsCLI, ListAlertsCLI, ListServicesCLI, ListTeamsCLI, and ListSchedulesCLI filter values are all updated in this PR to use neturl.QueryEscape, but the equivalent filter values appended in ListOnCallsCLI are left as raw string concatenation. If a user passes a --schedule-id or --user-id value that contains characters like + or &, the resulting query string would be silently malformed and the filter ignored.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/api/client.go
Line: 2965-2979
Comment:
**OnCalls filter values not URL-encoded**
The `ListIncidentsCLI`, `ListAlertsCLI`, `ListServicesCLI`, `ListTeamsCLI`, and `ListSchedulesCLI` filter values are all updated in this PR to use `neturl.QueryEscape`, but the equivalent filter values appended in `ListOnCallsCLI` are left as raw string concatenation. If a user passes a `--schedule-id` or `--user-id` value that contains characters like `+` or `&`, the resulting query string would be silently malformed and the filter ignored.
How can I resolve this? If you propose a fix, please make it concise.The API expects filter[schedule_ids], filter[service_ids], etc. but the CLI was sending singular forms (filter[schedule_id]) which the server silently ignores. Co-authored-by: Cursor <cursoragent@cursor.com>
Allow filtering by human-readable names instead of opaque IDs: --schedule="Primary On-Call" (resolves via /v1/schedules) --service="API Gateway" (resolves via /v1/services) --team="Platform Engineering" (resolves via /v1/teams) --user="alice@example.com" (resolves via /v1/users) Each name flag is mutually exclusive with its ID counterpart. User lookup uses filter[email] for addresses containing @, filter[search] otherwise. Also adds --team-id/--team flags (maps to filter[group_ids]), URL-encodes filter values to handle spaces and special chars, and refactors tests with addShiftsFlags/addWhoFlags helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
bee3d7d to
c096974
Compare
Summary
/v1/oncallsendpoint requires pluralquery param names (e.g.
filter[user_ids][],filter[team_ids][]). Theprevious singular forms were silently ignored by the API. See
https://docs.rootly.com/api-reference/oncalls/list-on-calls for the
expected parameter names.
oncall shiftsandoncall whonow accept--user-nameand--team-nameflags. These do a local resolve (list all,match by name) when an ID isn't known, making the CLI more ergonomic for
interactive use.
Changes
internal/api/client.go— fix param pluralization; add name-resolutionhelpers for users and teams
internal/cmd/oncall/oncall.go— shared filter-flag wiringinternal/cmd/oncall/shifts.go/who.go— expose new--user-name/--team-nameflagsinternal/cmd/oncall/cmd_test.go— expanded test coverage for both fixes